<template>
  <div id="SearchMould">
    <div class="goods-list">
      <div
        v-for="item in likeList"
        :key="item.id"
        class="goods-item"
        @click="todetail(item)"
      >
        <div class="goods-img">
          <img
            :src="item.defaultAlbum"
            alt=""
          >
        </div>
        <div class="goods-info">
          <div class="name">
            {{ item.cProductShowName }}{{ item.cModelDescription }}
          </div>
          <div class="price">
            ￥{{ item.fSalePrice }}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import bus from '@/api/eventBus'
export default {
  name: "SearchMould",
  components: {},
  props: {
    listdata: {
      type: Array,
      default: function () {
        return [];
      },
    },
  },
  data() {
    return {
      likeList: [],
      PageStatus: true
    };
  },
  mounted() {
    bus.$on('ListData', data =>{
      console.log('asdas', data)
      if(data.length === 0) {
        this.PageStatus = true
      } else {
        this.PageStatus = false
        this.likeList = data  
      }
    })
  },
  methods: {
    // 商品详情
    todetail(item) {
      this.$router.push({
        path: "/fruit/detail",
        query: {
          id: item.pid,
          iShopId: item.iShopId
        },
      })
    }
  },
};
</script>

<style scoped lang="scss">
#SearchMould {
  padding: 0 16.19rem;
  margin-top: 2.19rem;
  display: flex;
  flex-direction: column;

//   .title {
//     font-size: 1.13rem;
//     font-family: Microsoft YaHei;
//     font-weight: bold;
//     color: #333333;
//   }

  .goods-list {
    margin-top: 1.88rem;
    width: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;

    .goods-item {
      width: 24%;
      height: 20.88rem;
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-right: 1.333333%;
      margin-bottom: 2.38rem;
      cursor: pointer;

      &:nth-child(4n) {
        margin-right: 0;
      }

      .goods-img {
        width: 100%;
        height: 18rem;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #fff;

        img {
          width: 15rem;
          height: 15rem;
          object-fit: contain;
        }
      }

      .goods-info {
        width: 17.1rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        margin-top: 0.63rem;

        .name {
          font-size: 0.88rem;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: #040000;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          width: 100%;
        }

        .price {
          font-size: 1.09rem;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: #f0406f;
          margin-top: 0.38rem;
        }
      }
    }
  }
}
</style>
